/* Copyright (C) 2010 Fredrique Samuels, fredriquesamuels@gmail.com 

 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef TRI_STRING_H_
#define TRI_STRING_H_

#include <stdlib.h>
#include "utils.h"
#include "object.h"

namespace tri{

class TString{
	
	friend std::ostream& operator<<( std::ostream&, const tri::TString&);
	
public:
	/**
	 * Creates an empty string.
	 */
	TString();
	
	/**
	 * Preset string value
	 */
	TString(std::string s);
	TString(char* s);
	TString(TString& s);
	
	/**
	 * Get string value
	 */
	std::string getValue() const;
	
	/**
	 * Returns true is the string value 
	 * can be converted to a number
	 */
	bool isNumber() const;
	
	/**
	 * Pre-Condition : isNumber() must be true
	 * Get int value
	 */
	int toInteger() const;
	
	/**
	 * Pre-Condition : isNumber() must be true
	 * Get float value
	 */
	float toFloat() const;
	
	/**
	 * Return String value; 
	 */
	std::string toString() const;
	
	/**
	 * Get C style value
	 */
	const char* c_str() const;
	
	/**
	 * Clear string buffer
	 */
	void clear();
	
	/**
	 * Returns true is string starts with substring 
	 */
	bool startsWith(std::string ss) const;
	
	/**
	 * Returns true is string ends with substring
	 */
	bool endsWith(std::string ss) const;
	
	//========== overload operators ==============
	bool operator==(const tri::TString &s);

	TString& operator=(const tri::TString &s);
	TString& operator=(const std::string &s);
	TString& operator=(const char* s);
	TString& operator=(const float &s);

	TString& operator+=(const tri::TString &s);
	TString& operator+=(const std::string &s);
	TString& operator+=(const char* s);
	TString& operator+=(const float s);
	
//	TString operator+(const tri::TString &s);
	
private:
	std::string m_Value;
};

}

#endif 
